Hello,
Module m = current
Object obj
Module archiveModule = edit("/Requirements/Archive of Marketing Requirements", true )
void InLinks(Object hObject, Module archiveModule)
{
// Follow the in-links from the selected object (hObject)
Object hInObj = null
ModName_ inModRef = null
LinkRef lr = null
Link in_Link = null
string linkSourcePath = null
int asnoCurrent = 0
Object curr_obj = null
asnoCurrent = hObject."Absolute number"
curr_obj = object(asnoCurrent, archiveModule)
if (null curr_obj || isDeleted(curr_obj))
{
print "false: " asnoCurrent "\n"
}
else
{
// find the source (other end) of the in-link
for lr in hObject <- "*" do
{
// get the full path to the link source
// for in-links this is always in the other module
linkSourcePath = fullName(source lr)
// check that the returned path is valid
if (exists(module linkSourcePath) == true)
{
// check to see if the module is already open
if (open(module linkSourcePath) == false)
{
// open it if it is closed
edit(linkSourcePath, true)
}
}
}
// now we know for sure those modules are open, we can do the real work
for in_Link in hObject <- "*" do
{
// check the module at the other end of the link
inModRef = source in_Link
if (null inModRef) {continue}
// check the object at the other end of the link
hInObj = source in_Link
if (null hInObj) {continue}
if (isDeleted(hInObj)) {continue}
//and finally do something useful with the source object
hInObj->curr_obj
}
}
}
void OutLinks(Object hObject, Module archiveModule)
{
//
// This code snippet will follow the outlinks from a given object. (hObject)
//
//Declarations
Object hTargetObj = null
Module targetModule = null
Link outLink = null
int asnoCurrent = 0
Object curr_obj = null
asnoCurrent = hObject."Absolute number"
curr_obj = object(asnoCurrent, archiveModule)
if (null curr_obj || isDeleted(curr_obj))
{
print "false: " asnoCurrent "\n"
}
else
{
// now we know for sure those modules are open, we can do the real work
for outLink in hObject -> "*" do
{
// full path to the module at the other end of the out_link
string sTargetPath = fullName(target outLink)
if (null sTargetPath) {continue}
// only relevant if module exists with r access
if (exists(module sTargetPath) == true)
{
// ensure module is open
targetModule = read(sTargetPath, false)
}
//check that the target Module still exists
if (null targetModule ) {continue}
//check that the target object still exists
hTargetObj = target outLink
if (null hTargetObj) {continue}
if (isDeleted(hTargetObj)) {continue}
//now do something useful with the object
curr_obj->hTargetObj
}
}
}
for obj in entire m do
{
InLinks(obj, archiveModule)
OutLinks(obj, archiveModule)
}
SystemAdmin - Wed Oct 19 01:03:37 EDT 2011 |
Re: Creating Linksets on the fly. - Improving existing code.
As for LinkSets I am not sure where you want to go with the code? Automatically adding link pairing restrictions and linksets? Maybe the comments help a bit, regards, Mathias Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS |
Re: Creating Linksets on the fly. - Improving existing code. Mathias Mamsch - Wed Oct 19 04:28:46 EDT 2011
As for LinkSets I am not sure where you want to go with the code? Automatically adding link pairing restrictions and linksets? Maybe the comments help a bit, regards, Mathias Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS "You might want to think about links to baselines. Your code is ignoring those at the moment (since you use for L in o->"" instead of for L in all o->"" )" You would only be concerned about this if you were using baseline sets correct? Beacuse my understand is that all links are store in the "current" module and not in the baseline(s). Currently my project isn't using baseline sets. Thank you, Jim |
Re: Creating Linksets on the fly. - Improving existing code. SystemAdmin - Wed Oct 19 10:38:37 EDT 2011 Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS |